package com.ruoyi.zhongchuangauto.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zhongchuangauto.domain.OrderMailLog;
import com.ruoyi.zhongchuangauto.service.IOrderMailLogService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 订单邮件发送日志Controller
 * 
 * @author ruoyi
 * @date 2025-09-10
 */
@RestController
@RequestMapping("/zhongchuangauto/zclog")
public class OrderMailLogController extends BaseController
{
    @Autowired
    private IOrderMailLogService orderMailLogService;

    /**
     * 查询订单邮件发送日志列表
     */
    @PreAuthorize("@ss.hasPermi('zhongchuangauto:zclog:list')")
    @GetMapping("/list")
    public TableDataInfo list(OrderMailLog orderMailLog)
    {
        startPage();
        List<OrderMailLog> list = orderMailLogService.selectOrderMailLogList(orderMailLog);
        return getDataTable(list);
    }

    /**
     * 导出订单邮件发送日志列表
     */
    @PreAuthorize("@ss.hasPermi('zhongchuangauto:zclog:export')")
    @Log(title = "订单邮件发送日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OrderMailLog orderMailLog)
    {
        List<OrderMailLog> list = orderMailLogService.selectOrderMailLogList(orderMailLog);
        ExcelUtil<OrderMailLog> util = new ExcelUtil<OrderMailLog>(OrderMailLog.class);
        util.exportExcel(response, list, "订单邮件发送日志数据");
    }

    /**
     * 获取订单邮件发送日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('zhongchuangauto:zclog:query')")
    @GetMapping(value = "/{logId}")
    public AjaxResult getInfo(@PathVariable("logId") Long logId)
    {
        return success(orderMailLogService.selectOrderMailLogByLogId(logId));
    }

    /**
     * 新增订单邮件发送日志
     */
    @PreAuthorize("@ss.hasPermi('zhongchuangauto:zclog:add')")
    @Log(title = "订单邮件发送日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OrderMailLog orderMailLog)
    {
        return toAjax(orderMailLogService.insertOrderMailLog(orderMailLog));
    }

    /**
     * 修改订单邮件发送日志
     */
    @PreAuthorize("@ss.hasPermi('zhongchuangauto:zclog:edit')")
    @Log(title = "订单邮件发送日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OrderMailLog orderMailLog)
    {
        return toAjax(orderMailLogService.updateOrderMailLog(orderMailLog));
    }

    /**
     * 删除订单邮件发送日志
     */
    @PreAuthorize("@ss.hasPermi('zhongchuangauto:zclog:remove')")
    @Log(title = "订单邮件发送日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{logIds}")
    public AjaxResult remove(@PathVariable Long[] logIds)
    {
        return toAjax(orderMailLogService.deleteOrderMailLogByLogIds(logIds));
    }
}
